//
//  HeaderCollectionReusableView.m
//  GOGOTravel
//
//  Created by dllo on 16/1/30.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "HeaderCollectionReusableView.h"

@interface HeaderCollectionReusableView ()

@property (nonatomic, retain) UILabel *label;
@property (nonatomic, retain) UIView *view1;
@property (nonatomic,retain) UIButton *button;
@property (nonatomic, retain) NSNumber *moreLLL;
@end

@implementation HeaderCollectionReusableView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.label = [[UILabel alloc] init];
        _label.frame = CGRectMake(7, 1, 300, 30);
        _label.font = [UIFont systemFontOfSize:20];
        [self addSubview:_label];
        [_label release];
        
        self.view1 = [[UIView alloc] init];
        _view1.frame = CGRectMake(13, 5, 4, 20);
        _view1.backgroundColor = [UIColor cyanColor];
        _view1.layer.cornerRadius = 3;
        _view1.layer.masksToBounds = YES;
        [self addSubview:_view1];
        [_view1 release];
        
    }
    return self;
}

- (void)dealloc{
    [_label release];
    [_view1 release];
    [_button release];
    [_moreLLL release];
    [super dealloc];
}
- (void)setTitle:(NSString *)title more:(NSNumber *)more{
    _label.text = [NSString stringWithFormat:@"   %@ ", title];
    self.moreLLL = more;
    
    NSString *more1 = [more stringValue];
    if ([more1  isEqual: @"3"] || [more1  isEqual: @"6"] || [more1  isEqual: @"8"]) {
        [self createButton];
        _button.hidden = NO;
    }else{
        //重用问题
        _button.hidden = YES;
    }
    
    
}

- (void)createButton{
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    _button.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 50, -5, 50, 40);
    NSString *str = [NSString stringWithFormat:@"全部 >"];
    [_button setTitle:str forState:UIControlStateNormal];
    _button.titleLabel.font = [UIFont systemFontOfSize:14];
    [_button setTitleColor:UIColorFromRGB(0x099cc) forState:UIControlStateNormal];
    [_button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_button];
}


- (void)buttonAction:(UIButton *)button{
      NSString *more1 = [_moreLLL stringValue];
    if ([more1  isEqual: @"3"]) {
        [self.delegate jumpToMoreVc:@"http://api.breadtrip.com/destination/index_places/3/"];
    }
    
    if ([more1  isEqual: @"6"]) {
        [self.delegate jumpToMoreVc:@"http://api.breadtrip.com/destination/index_places/6/"];
    }
    
    
    if ([more1  isEqual: @"8"]) {
        [self.delegate jumpToMoreVc:@"http://api.breadtrip.com/destination/index_places/8/"];
    }
    
    
}


@end
